<html lang="zh-CN">

<head>
    <title>比翼鸟剧场</title>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
    <link rel="shortcut icon" type="image/x-icon" href="https://video-h5.wqxsw.com/wxxcx/static/shortlink/safe.png">
    <link rel="icon" href="https://video-h5.wqxsw.com/wxxcx/static/shortlink/safe.png">
    <style>
        body,
        .full {
            background-color: #fff;
        }

        .full {
            margin: 0 auto;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            text-align: center;
            font-size: 20px;
        }

        .top_title {
            height: 40px;
            line-height: 40px;
            display: flex;
            justify-content: center;
            font-size: 17px;
        }

        .top_title>div {
            display: flex;
            align-items: center;
            margin-right: 6px;
        }

        .top_title img {
            width: 17px;
            height: 20px;
            margin-top: 1px;
        }

        .content {
            position: absolute;
            bottom: 130px;
            width: 100%;
            box-sizing: border-box;
            padding: 0 20px;
        }

        .content div {
            margin-bottom: 26px;
        }

        .image_box {
            text-align: center;
        }

        .image_box img {
            width: 88px;
            height: 71px;
        }

        .content .cliff_bottom {
            margin-bottom: 100px;
        }

        .btn {
            height: 60px;
            line-height: 60px;
            background: #09e23b;
            border-radius: 10PX;
            color: #fff;
        }

        .content .btn {
            margin-bottom: 70px;
        }

        .bottom_title {
            position: relative;
            font-size: 18px;
        }

        .bottom_title span {
            color: #09e23b;
        }

        .bottom_title .arrowhead {
            width: 80px;
            position: absolute;
            top: -60px;
            left: 50%;
            transform: translate(-50%, 0);
            animation: scaleout 1.5s infinite ease-in-out;
        }

        .bottom_title .arrowhead img {
            width: 100%;
        }

        @keyframes scaleout {
            0% {
                top: -60px;
            }

            25% {
                top: -45px;
            }

            50% {
                top: -60px;
            }

            75% {
                top: -45px;
            }

            100% {
                top: -60px;
            }
        }


        .weChat_footer {
            width: 100%;
            text-align: center;
            position: absolute;
            bottom: 40px;
            font-size: 12px;
            color: #666666;
        }

        .weChat_footer img {
            height: 16px;
            margin-bottom: 20px;
        }

        .app_name {
            font-size: 14px;
            font-weight: 600;
            color: #242424;
        }
    </style>
</head>

<body>
    <div class="page full">
        <div class="top_title">
            <div><img src="https://video-h5.wqxsw.com/wxxcx/static/shortlink/safe.png" alt=""></div> 
            本链接经过SSL安全加密,请放心点击
        </div>
        <div class="content">
            <div class="image_box"> <img src="https://video-h5.wqxsw.com/wxxcx/static/shortlink/weixin.png" alt="">
            </div>
            <div class="cliff_bottom">正在跳转到微信...</div>
            <div class="">如未自动打开微信请点击下方按钮</div>
            <div class="btn"></div>
            <div class="bottom_title">
                点击上方 <span>绿色按钮</span> 跳转到微信
                <div class="arrowhead"> 
                    <img src="https://video-h5.wqxsw.com/wxxcx/static/shortlink/click-icon.png" alt=""> 
                </div>
            </div>
        </div>
        <div class="weChat_footer">
            <img src="https://video-h5.wqxsw.com/wxxcx/static/shortlink/duanju.png" alt="">
            <div class="app_name"></div>
        </div>
    </div>
    <input id="app_name" type="hidden" value="比翼鸟剧场">
    <script src="https://shortplay.sybyn.top/admin/xadmin/js/jq.js"></script>

    <?php

    if (!empty($_SERVER['HTTP_USER_AGENT']) && !empty($_SERVER['REMOTE_ADDR'])) {
        // $log = fopen('./land_page.txt', 'a+');
        // fwrite($log, date('Y-m-d H:i:s').' ：'.$_SERVER['REMOTE_ADDR'].' ； '.$_SERVER['HTTP_USER_AGENT'].'。'.PHP_EOL);
        // fclose($log);
        // file_put_contents('./monitoring_link.txt', date('Y-m-d H:i:s').' ：'.json_encode($_SERVER).';'.PHP_EOL, FILE_APPEND);
        // file_put_contents('./monitoring_link.txt', date('Y-m-d H:i:s').' ：'.$_SERVER['REMOTE_ADDR'].' ； '.$_SERVER['HTTP_USER_AGENT'].'。'.PHP_EOL, FILE_APPEND);
        $ip = $_SERVER['REMOTE_ADDR'];

        // if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        //     $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
        //     $pos = array_search('unknown', $arr);
        //     if (false !== $pos) unset($arr[$pos]);
        //     $ip  = trim($arr[0]);
        // } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
        //     $ip = $_SERVER['HTTP_CLIENT_IP'];
        // } elseif (isset($_SERVER['REMOTE_ADDR'])) {
        //     $ip = $_SERVER['REMOTE_ADDR'];
        // }

        $bool = strpos($_SERVER['HTTP_USER_AGENT'], 'Android');
        if ($bool) {
            // Android
            $regx = '/Build(.*?) /is';
            preg_match($regx, $_SERVER['HTTP_USER_AGENT'], $match);

            $userAgent = $match[1];
        } else {
            // iOS
            $regx = '/\((.*?)\)/';
            preg_match($regx, $_SERVER['HTTP_USER_AGENT'], $match);
            $userAgent = $match[1];
        }
        $userAgent = strtoupper(str_replace(' ', '', $userAgent));

        if (!empty($_GET['link_id'])) {
            file_put_contents('./land_page.txt', date('Y-m-d H:i:s').' ：'.$_GET['link_id'].' ； '.$ip.' ； '.$userAgent.' ； '.$_SERVER['HTTP_USER_AGENT'].' 。'.PHP_EOL, FILE_APPEND | LOCK_EX);
        } else {
            file_put_contents('./land_page.txt', date('Y-m-d H:i:s').' ：'.$ip.' ； '.$userAgent.' ； '.$_SERVER['HTTP_USER_AGENT'].' 。'.PHP_EOL, FILE_APPEND | LOCK_EX);
        }

        echo "<script>var ip='".$ip."';</script>"; // 传递给javascript
        echo "<script>var ua='".$userAgent."';</script>"; // 传递给javascript
    } else {
        echo "<script>var ip='';</script>";
        echo "<script>var ua='';</script>";
    }

    ?>

    <script>
        var params = window.location.search;
        var queryParams = {}
        var linkIdInfo;

        // 处理url参数
        var par1 = decodeURIComponent(params)
        if (par1.split('?').length > 1) {
            par1.split('?')[1].split('&').map(i => {
                queryParams[i.split('=')[0]] = i.split('=')[1]
            })
        }
        linkIdInfo = JSON.parse(localStorage.getItem(queryParams["link_id"]))
        if(linkIdInfo){
            $('.app_name').text(linkIdInfo.applet_name)
            $('.btn').text('点击前往 ' + linkIdInfo.applet_name)
        }

        queryParams.ip = ip;
        queryParams.ua = ua;

        $.ajax({
            type: "get",
            url: 'https://shortplay.sybyn.top/api/wx/getWxUrl',
            data: queryParams,
            success: (res) => {
                if (res.code == 200) {
                    var localStorageItem = {
                        url: res.data.url_link,
                        applet_name:res.data.applet_name,
                        time: new Date().getTime() + 7 * 24 * 60 * 60 * 1000
                    }
                    localStorage.setItem(queryParams["link_id"], JSON.stringify(localStorageItem));
                    $('.app_name').text(res.data.applet_name)
                    $('.btn').text('点击前往 ' + res.data.applet_name)
                    jumpFun(res.data.url_link)
                } else {
                    alert(res.message)
                }
            },
            error: (err) => {
                alert(err.message)
            }
        })
        // 注册手动点击跳转方法
        $('.btn').on('click', function () {
            location.href = JSON.parse(localStorage.getItem(queryParams["link_id"])).url
        })

        // 跳转方法
        function jumpFun(url) {
            console.log('跳转url', url)
            location.href = url
        }
    </script>
</body>

</html>